home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 126-150 / disk_134 / dme / main.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  16KB  |  746 lines

  1.  
  2. /*
  3.  * MAIN.C
  4.  *
  5.  *    (C)Copyright 1987 by Matthew Dillon, All Rights Reserved.
  6.  *
  7.  */
  8.  
  9. #include "defs.h"
  10.  
  11. #define IDCMPFLAGS   CLOSEWINDOW|NEWSIZE|RAWKEY|MOUSEBUTTONS|ACTIVEWINDOW|MOUSEMOVE|MENUPICK
  12.  
  13. extern WIN *OpenWindow();
  14. extern char *menu_cmd();
  15.  
  16. NW Nw = {
  17.    0, 1, 0  , 0  , -1, -1,  /*    width, height filled in by program */
  18.    IDCMPFLAGS,
  19.    ACTIVATE|WINDOWSIZING|WINDOWDRAG|WINDOWDEPTH|WINDOWCLOSE|NOCAREREFRESH|RMBTRAP,
  20.    NULL, NULL, (ubyte *)"   WAIT   ",
  21.    NULL, NULL,
  22.    32, 32, -1, -1,
  23.    WBENCHSCREEN
  24. };
  25.  
  26. short Sharedrefs;
  27. short Oldtlen = 999;      /*  Old Title Length      */
  28. struct MsgPort *Sharedport;
  29. DISKOBJ *Do;
  30. WBS    *Wbs;
  31.  
  32. WIN *Win;
  33. RP  *Rp;
  34.  
  35. short Xsize,  Ysize;        /* font character sizes        */
  36. short Rows,  Columns;        /* character rows/cols available       */
  37. short Xbase,  Ybase;        /* offset pixel base for display       */
  38. short XTbase,YTbase;        /* used for text display           */
  39. short Xpixs,  Ypixs;        /* actual # X/Y pixels available       */
  40. short Mx, My;
  41.  
  42. ubyte *av[8];
  43. char Quitflag;
  44. char Overide;
  45. char SizeOveride;
  46. char Wdisable = 1;        /* Disable icon save               */
  47. char MShowTitle, MForceTitle;
  48. short Nwwidth, Nwheight, Nwtopedge, Nwleftedge, Nwtmpwidth, Nwtmpheight;
  49.  
  50. int Enable_Abort;
  51.  
  52. extern WIN   *opensharedwindow();
  53. extern IMESS *GetMsg();
  54.  
  55. static char *Ffile;
  56.  
  57. main(mac, mav)
  58. char *mav[];
  59. {
  60.     register IMESS *im;     /*    intuition message        */
  61.     char nf, ni;        /*    # files on command line     */
  62.     char notdone;        /*    for endless loop        */
  63.     char iawm = 0;        /*    overide mouse buttons        */
  64.     char dontwait = 0;        /*    don't wait for a message    */
  65.     short i;
  66.     short Code;
  67.  
  68.     if (!openlibs(INTUITION_LIB|GRAPHICS_LIB))
  69.     exiterr("cannot open intuition or graphics library");
  70.     {
  71.     SCR scr;
  72.     GetScreenData(&scr, sizeof(scr), WBENCHSCREEN, NULL);
  73.     Nw.Width = (scr.Width > 640) ? 640 : scr.Width;
  74.     Nw.Height= scr.Height - ((scr.Height > 200) ? 40 : 1);
  75.     }
  76.  
  77.     init_command();
  78.  
  79.     Nwwidth    = Nw.Width;    /*  Parameters for new windows    */
  80.     Nwheight    = Nw.Height;
  81.     Nwtopedge    = Nw.TopEdge;
  82.     Nwleftedge    = Nw.LeftEdge;
  83.  
  84.     Enable_Abort= 0;        /*  disable break        */
  85.  
  86.     String  = (char *)malloc(1);        /*  initialize scanf variable   */
  87.     *String = 0;
  88.  
  89.  
  90.     if (mac == 0) {             /*  WORKBENCH STARTUP           */
  91.     long oldlock;
  92.  
  93.     Wdisable = 0;        /*  allow icon save        */
  94.     Wbs = (WBS *)mav;
  95.     if (!openlibs(ICON_LIB))
  96.         exiterr("unable to open icon library");
  97.     oldlock = CurrentDir(Wbs->sm_ArgList[0].wa_Lock);   /* Tool */
  98.     Do = GetDiskObject(Wbs->sm_ArgList[0].wa_Name);
  99.     CurrentDir(oldlock);
  100.     if (Do == NULL)
  101.         exiterr("unable to get disk object");
  102.     mac = 99;
  103.     }
  104.  
  105.     resethash();
  106.  
  107.     if (Do) {
  108.     ops(Do->do_ToolTypes, 1);
  109.     nf = Wbs->sm_NumArgs - 1;
  110.     Dirlock = Wbs->sm_ArgList[0].wa_Lock;
  111.     } else {
  112.     nf = ops(mav+1, 0);
  113.     }
  114.  
  115.     for (ni = 0, i = 1; i < mac; ++i) {
  116.     register char *str;
  117.     register DISKOBJ *dso;
  118.     long oldlock;
  119.     if (Wbs) {
  120.         if (i > nf)
  121.         break;
  122.         str = Wbs->sm_ArgList[i].wa_Name;
  123.         oldlock = CurrentDir(Wbs->sm_ArgList[i].wa_Lock);
  124.         if (dso = GetDiskObject(Wbs->sm_ArgList[i].wa_Name)) {
  125.         ops(dso->do_ToolTypes, 1);
  126.         FreeDiskObject(dso);
  127.         }
  128.         Dirlock = CurrentDir(oldlock);
  129.     } else {
  130.         str = mav[i];
  131.         if (*str == '-')
  132.         continue;
  133.     }
  134.     do_newwindow(nf > 1, ni * 10);
  135.     ++ni;
  136.     av[0] = (ubyte *)"newfile";
  137.     av[1] = (ubyte *)str;
  138.     do_edit();
  139.     MForceTitle = 1;
  140.     window_title();
  141.     }
  142.     if (nf == 0)                     /* no files to edit */
  143.     do_newwindow(nf > 1, ni * 10);
  144.  
  145.     mountrequest(0);
  146.     av[0] = NULL;
  147.     av[1] = (ubyte *)"s:.edrc";
  148.     do_source();
  149.     av[0] = NULL;
  150.     av[1] = (ubyte *)((Ffile) ? Ffile : ".edrc");
  151.     do_source();
  152.     mountrequest(1);
  153.     title("DME V1.29  \251Copyright 1988 Matthew Dillon,  All Rights Reserved                  ");
  154. loop:
  155.     if (!Ep->iconmode)
  156.     text_cursor(1);
  157.     for (notdone = 1; !Quitflag && notdone;) {
  158.     char mmove = 0;
  159.     short mqual;
  160.  
  161.     if (!Ep->iconmode)
  162.         window_title();
  163.     if (dontwait)
  164.         --dontwait;
  165.     else
  166.         WaitPort(Win->UserPort);
  167.  
  168.     /*
  169.      *  NOTE: due to operation of breakcheck(), the userport signal
  170.      *  may not be set even if there are messages pending.
  171.      */
  172.  
  173.     while (im = (IMESS *)GetMsg(Win->UserPort)) {
  174.         Msgchk = 1;
  175.         Abortcommand = 0;
  176.         Code = im->Code;
  177.         if (im->IDCMPWindow != Win) {
  178.         Overide = 0;
  179.         if (Comlinemode)
  180.             escapecomlinemode();
  181.         text_sync();
  182.         MShowTitle = 0;
  183.         if (!Ep->iconmode)
  184.             window_title();
  185.         if (text_switch(im->IDCMPWindow) == 0) {
  186.             ReplyMsg(im);
  187.             continue;
  188.         }
  189.         }
  190.         Mx = im->MouseX;
  191.         My = im->MouseY;
  192.         switch(im->Class) {
  193.         case NEWSIZE:
  194.         if (!Ep->iconmode) {
  195.             if (Comlinemode)
  196.             escapecomlinemode();
  197.             set_window_params();
  198.             if (!text_sync())
  199.                text_redisplay();
  200.             text_cursor(1);
  201.         }
  202.         break;
  203.         case MOUSEBUTTONS:
  204.         switch(Code) {
  205.         case SELECTDOWN:
  206.         case MENUDOWN:
  207.             if (Ep->iconmode || iawm) {
  208.             uniconify();
  209.             break;
  210.             }
  211.             ReportMouse(-1, Win);
  212.             uniconify();
  213.             text_cursor(0);
  214.             keyctl(NULL, im->Code|0x80, im->Qualifier);
  215.             text_cursor(1);
  216.             break;
  217.         case SELECTUP:
  218.         case MENUUP:
  219.             ReportMouse(0, Win);
  220.             break;
  221.         }
  222.         break;
  223.         case RAWKEY:
  224.         if ((im->Code & 0x80) == 0) {
  225.             if (Ep->iconmode) {
  226.             uniconify();
  227.             break;
  228.             }
  229.             text_cursor(0);
  230.             keyctl(im, im->Code, im->Qualifier);
  231.             text_cursor(1);
  232.         }
  233.         break;
  234.         case MENUPICK:
  235.         {
  236.             register char *str = menu_cmd(im);
  237.             if (str) {
  238.             str = strcpy(malloc(strlen(str)+1), str);
  239.             text_cursor(0);
  240.             do_command(str);
  241.             free(str);
  242.             text_cursor(1);
  243.             }
  244.         }
  245.         break;
  246.         case CLOSEWINDOW:
  247.         if (Comlinemode)
  248.             escapecomlinemode();
  249.         text_sync();
  250.         notdone = 0;
  251.         break;
  252.         case ACTIVEWINDOW:
  253.         if (!Ep->iconmode)
  254.             iawm = 1;
  255.         break;
  256.         case MOUSEMOVE:
  257.         mmove = 1;
  258.         mqual = im->Qualifier;
  259.         break;
  260.         }
  261.         if (im)
  262.         ReplyMsg(im);
  263.         if (notdone == 0 || Quitflag) {
  264.         dontwait = 2;
  265.         goto boom;
  266.         }
  267.     }
  268.     iawm = 0;
  269.     if (mmove) {
  270.         uniconify();
  271.         mmove = 0;
  272.         text_cursor(0);
  273.         keyctl(NULL, QMOVE, mqual);
  274.         text_cursor(1);
  275.     }
  276.     closesharedwindow(NULL);
  277.     }
  278. boom:
  279.     if (Ep->Modified && !Overide) {
  280.     uniconify();
  281.     Overide = 1;
  282.     title("*** File has been modified ***");
  283.     Quitflag = 0;
  284.     goto loop;
  285.     }
  286.     SetWindowTitles(Win, "", -1);
  287.     text_uninit();                        /* uninitialize text portion    */
  288.     closesharedwindow(Win);
  289.     if (Base) {
  290.     Quitflag = 0;
  291.     Win = Ep->Win;              /* make arbitrary other window act. */
  292.     Rp = Win->RPort;
  293.     if (!Ep->iconmode)
  294.         set_window_params();
  295.     text_load();
  296.     MShowTitle = 0;
  297.     goto loop;
  298.     }
  299.     closesharedwindow(NULL);
  300.     if (Do)
  301.     FreeDiskObject(Do);
  302.     closelibs(-1);
  303.     dealloc_hash();
  304. }
  305.  
  306. do_iconify()
  307. {
  308.     if (!Comlinemode)
  309.     iconify();
  310. }
  311.  
  312. do_tomouse()
  313. {
  314.     text_position((Mx-Xbase)/Xsize, (My-Ybase)/Ysize);
  315. }
  316.  
  317. iconify()
  318. {
  319.     if (!Ep->iconmode) {
  320.     Ep->Winx      = Win->LeftEdge;
  321.     Ep->Winy      = Win->TopEdge;
  322.     Ep->Winwidth  = Win->Width;
  323.     Ep->Winheight = Win->Height;
  324.     Nw.Height = 10;
  325.     Nw.Width  = 20 + 5*8 + strlen(Ep->Name)*8;
  326.     Nw.LeftEdge= Ep->IWinx;
  327.     Nw.TopEdge = Ep->IWiny;
  328.     if (Nw.LeftEdge + Nw.Width > Win->WScreen->Width)
  329.         Nw.LeftEdge = Win->WScreen->Width - Nw.Width;
  330.     if (Nw.TopEdge + Nw.Height > Win->WScreen->Height)
  331.         Nw.TopEdge = Win->WScreen->Height - Nw.Height;
  332.     Nw.Title = Ep->Wtitle;
  333.     Nw.Flags &= ~(WINDOWSIZING|WINDOWDEPTH);
  334.     Nw.Flags |= BORDERLESS;
  335.     sprintf(Ep->Wtitle, "%s %s    ", Ep->Name, ((Ep->Modified) ? "(mod)":""));
  336.     closesharedwindow(Win);
  337.     Win = Ep->Win = opensharedwindow(&Nw);
  338.     Nw.Flags |= WINDOWSIZING|WINDOWDEPTH;
  339.     Nw.Flags &= ~BORDERLESS;
  340.     Rp = Win->RPort;
  341.     }
  342.     Ep->iconmode = 1;
  343. }
  344.  
  345. uniconify()
  346. {
  347.     if (Ep->iconmode) {
  348.     Ep->IWinx = Win->LeftEdge;
  349.     Ep->IWiny = Win->TopEdge;
  350.     closesharedwindow(Win);
  351.     Nw.LeftEdge = Ep->Winx;
  352.     Nw.TopEdge  = Ep->Winy;
  353.     Nw.Width    = Ep->Winwidth;
  354.     Nw.Height   = Ep->Winheight;
  355.     Nw.Title = Ep->Wtitle;
  356.     Win = Ep->Win = opensharedwindow(&Nw);
  357.     menu_strip(Win);
  358.     Rp = Win->RPort;
  359.     set_window_params();
  360.     if (!text_sync())
  361.         text_redisplay();
  362.     text_cursor(1);
  363.     MShowTitle = 0;
  364.     window_title();
  365.     }
  366.     Ep->iconmode = 0;
  367. }
  368.  
  369.  
  370. do_newwindow(makesmall, deltaheight)
  371. {
  372.     WIN *win;
  373.     int msadj = makesmall;
  374.  
  375.     if (SizeOveride)
  376.     msadj = 0;
  377.     if (Ep)
  378.     text_sync();
  379.     Nw.Title = (ubyte *)"    OK    ";
  380.     Nw.Width = (Nwtmpwidth) ? Nwtmpwidth : Nwwidth;
  381.     Nw.Height= (Nwtmpheight)? Nwtmpheight: Nwheight;
  382.     Nwtmpwidth = Nwtmpheight = 0;
  383.     Nw.LeftEdge = Nwleftedge;
  384.     Nw.TopEdge    = Nwtopedge;
  385.     if (msadj > 0) {                    /* deltaheight must be valid    */
  386.     Nw.TopEdge = deltaheight + 16;
  387.     Nw.LeftEdge= 10*8;
  388.     Nw.Flags &= ~ACTIVATE;
  389.     Nw.Width = 40*8;
  390.     Nw.Height= 10*8;
  391.     if (Nw.TopEdge + Nw.Height > 200)
  392.         Nw.TopEdge = deltaheight = 200 - Nw.Height;
  393.     }
  394.     win = opensharedwindow(&Nw);
  395.     menu_strip(win);
  396.     Nw.Flags |= ACTIVATE;
  397.     if (win) {
  398.     Win = win;            /* set new window   */
  399.     Rp = Win->RPort;
  400.     set_window_params();
  401.     text_init();                    /* initialize       */
  402.     text_load();
  403.     if (makesmall != -1)            /* if deltaheight valid */
  404.         Ep->IWiny = deltaheight + 16;
  405.     }
  406. }
  407.  
  408. WIN *
  409. TOpenWindow(nw)
  410. NW *nw;
  411. {
  412.     WIN *win;
  413.  
  414.     while ((win = OpenWindow(nw)) == NULL) {
  415.     if (nw->Width < 50 || nw->Height < 50)
  416.         break;
  417.     nw->Width -= 10;
  418.     nw->Height-= 10;
  419.     }
  420.     return(win);
  421. }
  422.  
  423.  
  424. WIN *
  425. opensharedwindow(nw)
  426. NW *nw;
  427. {
  428.     WIN *win;
  429.  
  430.     if (Sharedport)
  431.     nw->IDCMPFlags = NULL;
  432.     else
  433.     nw->IDCMPFlags = IDCMPFLAGS;
  434.     win = TOpenWindow(nw);
  435.     if (win) {
  436.     if (Sharedport) {
  437.         win->UserPort = Sharedport;
  438.         ModifyIDCMP(win, IDCMPFLAGS);
  439.     } else {
  440.         Sharedport = win->UserPort;
  441.     }
  442.     ++Sharedrefs;
  443.     }
  444.     return(win);
  445. }
  446.  
  447.  
  448. closesharedwindow(win)
  449. WIN *win;
  450. {
  451.     static WIN *wunlink;
  452.     register IMESS *im;
  453.     char notoktoclosenow = 0;
  454.  
  455.     if (win) {
  456.     SetWindowTitles(win, "", -1);
  457.     ClearMenuStrip(win);
  458.     Forbid();
  459.     win->UserPort = NULL;
  460.     ModifyIDCMP(win, GADGETUP);     /* NEVER occurs */
  461.  
  462.     notoktoclosenow = 1;
  463.  
  464.     Permit();
  465.     if (notoktoclosenow) {
  466.         win->UserData = (char *)wunlink;
  467.         wunlink = win;
  468.     } else {
  469.         CloseWindow(win);
  470.     }
  471.     --Sharedrefs;
  472.     } else {
  473.     if (Sharedrefs == 0 && Sharedport) {
  474.         DeletePort(Sharedport);
  475.         Sharedport = NULL;
  476.     }
  477.     for (win = wunlink; win; win = wunlink) {
  478.         wunlink = (WIN *)win->UserData;
  479.         CloseWindow(win);
  480.     }
  481.     wunlink = NULL;
  482.     }
  483. }
  484.  
  485.  
  486. getyn(text)
  487. char *text;
  488. {
  489.     int result;
  490.     ITEXT *body, *pos, *neg;
  491.  
  492.     body = (ITEXT *)AllocMem(sizeof(ITEXT), 0);
  493.     pos  = (ITEXT *)AllocMem(sizeof(ITEXT), 0);
  494.     neg  = (ITEXT *)AllocMem(sizeof(ITEXT), 0);
  495.     bzero(body, sizeof(ITEXT));
  496.     bzero(pos , sizeof(ITEXT));
  497.     bzero(neg , sizeof(ITEXT));
  498.     body->BackPen = pos->BackPen = neg->BackPen = 1;
  499.     body->DrawMode= pos->DrawMode= neg->DrawMode= AUTODRAWMODE;
  500.     body->LeftEdge = 10;
  501.     body->TopEdge  = 12;
  502.     body->IText    = (ubyte *)text;
  503.     pos->LeftEdge = AUTOLEFTEDGE;
  504.     pos->TopEdge = AUTOTOPEDGE;
  505.     pos->IText = (ubyte *)"OK";
  506.     neg->LeftEdge = AUTOLEFTEDGE;
  507.     neg->TopEdge = AUTOTOPEDGE;
  508.     neg->IText = (ubyte *)"CANCEL";
  509.     result = AutoRequest(Win,body,pos,neg,0,0,320,58);
  510.     FreeMem(body, sizeof(ITEXT));
  511.     FreeMem(pos , sizeof(ITEXT));
  512.     FreeMem(neg , sizeof(ITEXT));
  513.     return(result);
  514. }
  515.  
  516.  
  517. title(buf)
  518. char *buf;
  519. {
  520.     SetWindowTitles(Win, buf, -1);
  521.     Oldtlen = 999;
  522.     MShowTitle = 3;
  523. }
  524.  
  525. window_title()
  526. {
  527.     register int len, maxlen;
  528.  
  529.     if (memoryfail) {
  530.     title(" -- NO MEMORY -- ");
  531.     memoryfail = 0;
  532.     text_redisplay();
  533.     }
  534.     if (MForceTitle) {
  535.     MShowTitle = 0;
  536.     MForceTitle = 0;
  537.     }
  538.     if (MShowTitle) {
  539.     --MShowTitle;
  540.     return(0);
  541.     }
  542.     {
  543.     register char *mod;
  544.     mod = (Ep->Modified) ? " (modified)" : "          ";
  545.     sprintf(Ep->Wtitle, "%3ld/%-3ld %3ld %s%s  ", text_lineno(), text_lines(), text_colno()+1, text_name(), mod);
  546.     if (!text_imode())
  547.         strcat(Ep->Wtitle, "Ovr ");
  548.     len = strlen(Ep->Wtitle);
  549.     if (len < Columns && Columns < 128) {
  550.         bset(Ep->Wtitle+len, Columns - len + 1, ' ');
  551.         Ep->Wtitle[Columns + 1] = 0;
  552.     }
  553.  
  554.     Win->Title = Ep->Wtitle;
  555.     SetAPen(Rp, 0);
  556.     SetBPen(Rp, 1);
  557.     Move(Rp, 30, Win->RPort->Font->tf_Baseline+1);
  558.     maxlen = (Win->Width-96)/Win->RPort->Font->tf_XSize;
  559.     if (maxlen < 0)
  560.         maxlen = 0;
  561.     if (len > maxlen)
  562.         len = Oldtlen = maxlen;
  563.     if (Oldtlen > maxlen)
  564.         Oldtlen = maxlen;
  565.     Text(Rp, Ep->Wtitle, len);      /*  No flash                    */
  566.     while (Oldtlen - len >= (int)sizeof(Space)) {
  567.         Text(Rp, Space, sizeof(Space));
  568.         Oldtlen -= sizeof(Space);
  569.     }
  570.     if (Oldtlen - len > 0)
  571.         Text(Rp, Space, Oldtlen - len);
  572.     Oldtlen = len;            /*  Oldtlen might have been <    */
  573.     SetAPen(Rp, 1);
  574.     SetBPen(Rp, 0);
  575.     }
  576. }
  577.  
  578. set_window_params()
  579. {
  580.     Xsize = Rp->Font->tf_XSize;
  581.     Ysize = Rp->Font->tf_YSize;
  582.     Xbase = Win->BorderLeft;
  583.     Ybase = Win->BorderTop;
  584.     Xpixs   = Win->Width - Win->BorderRight - Xbase;
  585.     Ypixs   = Win->Height- Win->BorderBottom- Ybase;
  586.     Columns = Xpixs / Xsize;
  587.     Rows    = Ypixs / Ysize;
  588.     XTbase  =  Xbase;
  589.     YTbase  =  Ybase + Rp->Font->tf_Baseline;
  590. }
  591.  
  592.  
  593. exiterr(str)
  594. char *str;
  595. {
  596.     if (Output()) {
  597.     Write(Output(),str,strlen(str));
  598.     Write(Output(),"\n",1);
  599.     }
  600.     exit(1);
  601. }
  602.  
  603.  
  604. /*
  605.  *  Check break by scanning pending messages in the I stream for a ^C.
  606.  *  Msgchk forces a check, else the check is only made if the signal is
  607.  *  set in the I stream (the signal is reset).
  608.  */
  609.  
  610. breakcheck()
  611. {
  612.     IMESS *im;
  613.     register struct List *list = &Win->UserPort->mp_MsgList;
  614.  
  615.     if (Msgchk || (SetSignal(0,0) & (1<<Win->UserPort->mp_SigBit))) {
  616.     Msgchk = 0;
  617.     SetSignal(0,1<<Win->UserPort->mp_SigBit);
  618.  
  619.     im = (IMESS *)list->lh_Head;
  620.     Forbid();
  621.     for (; im != &list->lh_Tail; im = (IMESS *)im->ExecMessage.mn_Node.ln_Succ) {
  622.         if (im->Class == RAWKEY && (im->Qualifier & 0xFB) == 0x08 &&
  623.         im->Code == CtlC) {
  624.  
  625.         Permit();
  626.         SetSignal(SIGBREAKF_CTRL_C,SIGBREAKF_CTRL_C);
  627.         return(1);
  628.         }
  629.     }
  630.     Permit();
  631.     }
  632.     return(0);
  633. }
  634.  
  635. breakreset()
  636. {
  637.     SetSignal(0, SIGBREAKF_CTRL_C);
  638. }
  639.  
  640. /*
  641.  *  leftedge n
  642.  *  topedge  n
  643.  *  width    n
  644.  *  height   n
  645.  *  tmpwidth  n
  646.  *  tmpheight n
  647.  */
  648.  
  649. void
  650. do_windowparm()
  651. {
  652.     int val = atoi(av[1]);
  653.  
  654.     if (av[0][0] == 't' && av[0][1] == 'm') {   /*  tmpwidth/tmpheight  */
  655.     if (av[0][3] == 'w')
  656.         Nwtmpwidth = val;
  657.     if (av[0][3] == 'h')
  658.         Nwtmpheight= val;
  659.     return;
  660.     }
  661.     switch(av[0][0]) {
  662.     case 'l':
  663.     Nwleftedge = val;
  664.     break;
  665.     case 't':
  666.     Nwtopedge = val;
  667.     break;
  668.     case 'w':
  669.     Nwwidth = val;
  670.     break;
  671.     case 'h':
  672.     Nwheight = val;
  673.     break;
  674.     }
  675. }
  676.  
  677. /*
  678.  *  resize cols rows
  679.  */
  680.  
  681. do_resize()
  682. {
  683.     int cols = atoi(av[1]);
  684.     int rows = atoi(av[2]);
  685.     short width = (cols*Win->RPort->Font->tf_XSize) + Win->BorderLeft + Win->BorderRight;
  686.     short height= (rows*Win->RPort->Font->tf_YSize) + Win->BorderTop + Win->BorderBottom;
  687.  
  688.     if (width < 16 || height < 16 ||
  689.     width > Win->WScreen->Width - Win->LeftEdge ||
  690.     height > Win->WScreen->Height - Win->TopEdge) {
  691.     title ("window too big (try moving to upper left corner and retrying)");
  692.     return(0);
  693.     }
  694.     SizeWindow(Win, width - Win->Width, height - Win->Height);
  695.     Delay(50*2);    /* wait 2 seconds */
  696. }
  697.  
  698. ops(av, iswb)
  699. register char *av[];
  700. {
  701.     register short nonops;
  702.     register short i;
  703.     register long val;
  704.     register char *str;
  705.  
  706.     for (i = nonops = 0; str = av[i]; ++i) {
  707.     if (iswb) {
  708.         if (strncmp(str, "ARG", 3) == 0) {
  709.         while (*str && *str != '-')
  710.             ++str;
  711.         }
  712.     }
  713.     if (*str == '-') {
  714.         val = atoi(str+2);
  715.         switch(str[1]) {
  716.         case 'f':
  717.         Ffile = str+2;
  718.         break;
  719.         case 'b':
  720.         SizeOveride = 1;
  721.         break;
  722.         case 't':
  723.         Nwtopedge = val;
  724.         break;
  725.         case 'l':
  726.         Nwleftedge= val;
  727.         break;
  728.         case 'w':
  729.         SizeOveride = 1;
  730.         Nwwidth   = val;
  731.         break;
  732.         case 'h':
  733.         SizeOveride = 1;
  734.         Nwheight  = val;
  735.         break;
  736.         }
  737.     } else {
  738.         ++nonops;
  739.     }
  740.     }
  741.     return(nonops);
  742. }
  743.  
  744.  
  745.  
  746.